<?php
session_start();
$_SESSION["islogin"]=true;
$link =mysql_connect('localhost','root','');
if (!$link) {
	die('Not connected : ' . mysql_error());
}
$db_selected = mysql_select_db('seproject', $link);
if (!$db_selected) {
	die ('Cannot useSeproject : ' . mysql_error());
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css" />
<title>Wellcome to Charity Organization!</title>
</head>

<body>
<div id="container">
		<div id="header">
			<h1>ListOf<span class="off">Products</span></h1>
        </div>   
        
        <div id="menu">
			<ul>
				<a href="homeP.php">Back</a>
				<a href="Search.php">Search</a>
				<a href="Insert.php">Insert Item</a>
			</ul>
		</div>        
                
		<div id="content">
        <div id="content_main">
        	<?php
			$link =mysql_connect('localhost','root','');
			if (!$link) {
				die('Not connected : ' . mysql_error());
			}
			$db_selected = mysql_select_db('seproject', $link);
			if (!$db_selected) {
				die ('Cannot useSeproject : ' . mysql_error());
			}
			$query = mysql_query("SELECT * FROM `seproject`.`product`");
			?>
			<table cellspacing="10" border="0"   align="left" bgcolor="#FFFFFF"  bordercolor="#180000" frame="box">  
			<tr>
			<th>Product_ID</th>
			<th>Category</th>
			<th>Price</th>
			<th>Description</th>
			<th></th>
			<th></th>
			</tr>
			<?php
		for($i=0;$i<mysql_num_rows($query);$i++)
		{
				$a=mysql_fetch_row($query);
				?>
				<tr>
				<td><?php echo $a[0]; ?></td>
				<td><?php echo $a[1]; ?></td>
				<td><?php echo $a[2]; ?></td>
				<td><?php echo $a[3]; ?></td>
				<td><form  method="POST" action="EditProduct.php" align="right">
				<a href="http://localhost/se/slickred/EditProduct.php?Product_ID=<?php echo $a[0];?>" > Edit </a>
				</form></td>
				<td><form  method="POST" action="DeleteProduct.php" align="right">
				<a href="http://localhost/se/slickred/DeleteProduct.php?Product_ID=<?php echo $a[0];?>" > Delete </a>
				</form></td>
				</tr>
				<?php
		}
		?>
		</table>
        </div>
      </div>
   </div>
</body>
</html>
